/*
 * @(#) AppBaseAdapter.java 2016-1-21
 *
 * Copyright (c) 2010, HMI Technology. All Rights Reserved.
 * HMI Technology. CONFIDENTIAL
 */
package com.webkitlib.base;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.webkitlib.util.ViewHolder;

/**
 * 
 * 
 * @author 韩伟光
 * @version 1.0
 * @since 2016-1-21
 */
public abstract class AppBaseAdapter<T> extends BaseAdapter {
    protected ArrayList<T> mBase;
    protected Context ctx;
    private int item_id;
    public AppBaseAdapter(Context ctx, ArrayList<T> base,int itemVIewId) {
        this.ctx = ctx;
        this.item_id = itemVIewId;
        this.mBase = base;
    }
    @Override
    public int getCount() {
        return mBase == null ? 0 : mBase.size();
    }
    @Override
    public T getItem(int position) {
        return mBase.get(position);
    }
    @Override
    public long getItemId(int position) {
        return position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=ViewHolder.get(ctx, convertView, parent, item_id, position);
        converrt(holder, getItem(position));
        return holder.getmConvertView();
    }
    public abstract void converrt(ViewHolder holder,T t);
}

